package observability

import (
	"context"

	"github.com/sirupsen/logrus"
)

// Logger wraps logrus logger with additional context
type Logger struct {
	*logrus.Entry
	ctx context.Context
}

// NewLogger creates a new logger
func NewLogger(ctx context.Context) *Logger {
	logger := logrus.New()
	logger.SetFormatter(&logrus.JSONFormatter{})

	return &Logger{
		Entry: logrus.NewEntry(logger),
		ctx:   ctx,
	}
}

// WithComponent adds component name to logger
func (l *Logger) WithComponent(component string) *Logger {
	return &Logger{
		Entry: l.Entry.WithField("component", component),
		ctx:   l.ctx,
	}
}

// WithOperation adds operation name to logger
func (l *Logger) WithOperation(op string) *Logger {
	return &Logger{
		Entry: l.Entry.WithField("operation", op),
		ctx:   l.ctx,
	}
}
